<!doctype html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>后台登录-X-admin2.2</title>
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="stylesheet" href="css/font.css">
        <link rel="stylesheet" href="css/xadmin.css">
         <link rel="stylesheet" href="css/theme3177.min.css" />
        <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
        <script src="lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="js/xadmin.js"></script>
        <script type="text/javascript" src="js/global.js" ></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
        <script>
            // 是否开启刷新记忆tab功能
            // var is_remember = false;
        </script>
    </head>
    <body class="index">
        <!-- 顶部开始 -->
        <div class="container">
            <div class="logo">
                <a href="./index.html">喵喵喵系统管理</a></div>
            <div class="left_open">
                <a><i title="展开左侧栏" class="iconfont">&#xe699;</i></a>
            </div>
            <ul class="layui-nav right" lay-filter="">
            	<li class="layui-nav-item" lay-unselect="">
            		<a onclick="xadmin.add_tab('消息中心','message.html')">
                                    	<i class="layui-icon layui-icon-notice"></i>  
              
              <!-- 如果有新消息，则显示小圆点 -->
              <span id="span"></span>
              </a>
          </li>
                <li class="layui-nav-item">
                   <a href="javascript:;"><span id="spName">
							</span></a>
							<dl class="layui-nav-child">
								<!-- 二级菜单 -->	
								<dd>
									<a href="#" id="xgmm">修改密码</a>
								</dd>
								<dd>
									<a href="#" id="logout">安全退出</a>
								</dd>
							</dl>
                </li>
                <li class="layui-nav-item to-index">
                    <a href="/">前台首页</a></li>
            </ul>
        </div>
        <!-- 顶部结束 -->
        <!-- 中部开始 -->
        <!-- 左侧菜单开始 -->
        <div class="left-nav">
             <div id="side-nav">
                <ul id="nav">
                </ul>
             </div>
        </div>
        <!-- 左侧菜单结束 -->
        <!-- 右侧主体开始 -->
        <div class="page-content">
            <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
                <ul class="layui-tab-title">
                    <li class="home">
                        <i class="layui-icon">&#xe68e;</i>我的桌面</li></ul>
                <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
                    <dl>
                        <dd data-type="this">关闭当前</dd>
                        <dd data-type="other">关闭其它</dd>
                        <dd data-type="all">关闭全部</dd></dl>
                </div>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <iframe src='./welcome.html' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
                    </div>
                </div>
                <div id="tab_show"></div>
            </div>
        </div>
        <div class="page-content-bg"></div>
        <style id="theme_style"></style>
        <!-- 右侧主体结束 -->
        
        
        <!--详情-->
			<div id="xqDiv" class="layui-form-item" style="margin-top: 10px; margin-left:10px;display: none;">
				<form id="xqForm" lay-filter="updateForm" class="layui-form" method="post" onsubmit="return false;">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">学生名称</label>
							<div class="layui-input-inline"style="width: 150px;">
								<input type="hidden" id="mid" disabled class="layui-input">
								<input type="text" id="name" disabled class="layui-input">
							</div>
						</div>
						
						
					</div>
					<div class="layui-form-item">
					<div class="layui-inline">
							<label class="layui-form-label">网络咨询：</label>
					          <div class="layui-input-inline" style="width: 150px;">
						           <input type="text" id="user" disabled class="layui-input">
						      </div>
						</div>
					</div>
					
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">时间：</label>
					          <div class="layui-input-inline" style="width: 350px;">
						           <input type="text" id="time" disabled class="layui-input">
						      </div>
						     </div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">内容：</label>
					          <div class="layui-input-inline" style="width: 350px;">
						           <textarea id="msg" disabled class="layui-textarea"></textarea>
						      </div>
						     </div>
					</div>
				</form>
			</div>
        <!-- 中部结束 -->
        <script>//获取登陆用户的姓名
        //自动分配咨询师
        	var zdfpzxs=1;
				localStorage.value=zdfpzxs;
        var ws=null;
	$(document).ready(function(){
	if ('WebSocket' in window) {
		var urlPrefix = "ws://localhost:8080/chat-room/";
		var uname = globalData.getCurUName();
		ws = new WebSocket(urlPrefix + uname);
		
	}else{
		alert("你的浏览器不支持WebSocket");
	}
	ws.onmessage=function(r){
				layer.alert(r.data,{
								btn:['查看','忽略'],
								icon:7,
								offset: 'rb',
								btn1:function(index){
									layer.close(index);
									$.post(globalData.server+"/msg/getOneMsg",{'token':globalData.getCurToken(),'askerid':globalData.getCurUName()},function(aaa){
										if(aaa!=null){
											$.post(globalData.server+"cx/findByStuId",{"stuid":aaa.stuid,"token":globalData.getCurToken()},function(a){
											  		if(a!=null){
											  			$("#name").val(a);
											  			console.log(a);
											  		}
											  })
											$("#mid").val(aaa.mid);
			            					$("#msg").val(aaa.msg);
			            					$("#time").val(aaa.time);
											console.log(res);
										}
											  
									})
									$.post(globalData.server+"cx/findByUserId",{"uid":globalData.getCurUid(),"token":globalData.getCurToken()},function(res){
											  		if(res!=null){
											  			$("#user").val(res);
											  			console.log(res);
											  		}
											 })
									
									layer.open({
							type: 1,
							title: '详情信息',
							content: $("#xqDiv"),
							area: ['550px', '500px'],
							end:function(){
								$.post(globalData.server+"/msg/upMessage",{"token":globalData.getCurToken(),"mid":$("#mid").val()},function(r){
							if(r=0){
								layer.msg("修改失败");
							}else{
								parent.location.reload();
							}
						})
							}
						})
									
								},
								btn2:function(){
									layer.msg("忽略");
								}
							})
		}
      })  
	layui.use(['layer','element','form'],function(){
		var $=layui.$;
		var layer=layui.layer;
		var element=layui.element;
		var form=layui.form;
		$("#spName").html(globalData.getCurUName());
		
		
		$(function() {
			$.post(globalData.server+"/msg/getWdMessage",{"token":globalData.getCurToken(),"askerid":globalData.getCurUName()},function(res){
				if(res==null||res==""){
					$("#span").removeClass("layui-badge-dot");
				}else{
					$("#span").addClass("layui-badge-dot");
				}
			})
					$.post(globalData.server + "module/getUserIdModules", {
						"id": globalData.getCurUid,
						"token": globalData.getCurToken()
					}, function(data1) {
						$("#nav").html("");
						$.each(data1, function(n, value) {
							var s = '<li><a href="javascript:;"><i class="iconfont left-nav-li" lay-tips=' + value.title + '>&#xe6b8;</i><cite>' + value.title + '</cite><i class="iconfont nav_right">&#xe697;</i></a><ul class="sub-menu">';
							for(var i = 0; i < value.children.length; i++) {
								var cr = value.children[i];
								s += '<li><a onclick="xadmin.add_tab(\'' + cr.title + '\',\'' + cr.href + '\')"><i class="iconfont">&#xe6a7;</i><cite>' + cr.title + '</cite></a></li>';
							}
							s += "</ll></li>";
							$("#nav").append($(s));
						});
						element.render("nav", "side");

					}, "json");
				})
		
		//修改密码
		$("#xgmm").click(function(){
			layer.open({
				type:2,
				maxmin:true,
				title:"您正在修改密码",
				area:['440px','280px'],
				content:"updateMm.html"
			});
		})
		//退出登陆业务代码
		$("#logout").click(function(){
			layer.confirm('确定退出吗？',{
  				icon:3
			},function(){
				 $.post(globalData.server+"/QtUserCheck",{
        				"token":globalData.getCurToken(),
        				"uid":globalData.getCurUid(),
        				"time":dateFtt("yyyy-MM-dd", new Date())
        			},function(res){
        				if(res>0){
        					var url=globalData.server+"/QtCheck";
        			$.post(url,{
        				"uid":globalData.getCurUid(),
        				"time":dateFtt("yyyy-MM-dd", new Date()),
        				"token":globalData.getCurToken(),
        				"id":res
        			},function(res){
        				if(res>0){
							globalData.setUserInfo(null,null,null,null);
							if (ws){
								ws.close();
							}
							top.location.href="login.html";
        				}else{
        					layer.msg("请十分钟后再进行签退");
        				}
        			},"json")
        				}else{
        					layer.confirm("您确定不签到就退出吗？",function(){
							globalData.setUserInfo(null,null,null,null);
							top.location.href="login.html";
        					},function(){
							})
        				}
        			},"json")
			});
		
	})
			
			
		});
		
		var getSpeicalTime = function() {
					var now = new Date;
					now.setHours(now.getHours() + 1);
					return now;
				}
        //格式化时间
				function dateFtt(fmt, date) { //author: meizz 
					var o = {
						"M+": date.getMonth() + 1, //月份 
						"d+": date.getDate(), //日 
						"h+": date.getHours(), //小时 
						"m+": date.getMinutes(), //分 
						"s+": date.getSeconds(), //秒 
						"q+": Math.floor((date.getMonth() + 3) / 3), //季度 
						"S": date.getMilliseconds() //毫秒 
					};
					if(/(y+)/.test(fmt))
						fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
					for(var k in o)
						if(new RegExp("(" + k + ")").test(fmt))
							fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
					return fmt;
				}
        	
			
	
</script>
    </body>

</html>